<include file="Public:header" />
<div class="subnav">
  <div class="explain-col" style="position: relative;">
    <form name="searchForm" id="searchForm" method="GET" action="">
      搜索：
      <input type="text" name="keyword" id="keyword" size="30" placeholder="请输入关键词"  value="{$Think.get.keyword}" class="input-text"  style="height:20px; width:120px; color:#999" />

      <eq name="Think.session.user_id" value="1">
        <select name="user_id" id="user_id" onchange="searchForm.submit()">
          <option value="0">所属顾问</option>
          <volist name=":get_admin_list()" id="vo">
            <option value="{$vo.id}" {:selected($vo['id'],$_GET['user_id'])}>{$vo.username}</option>
          </volist>
        </select>
      </eq>
      <select name="source" id="source" onchange="searchForm.submit()">
        <option value="0">请选择咨询方式</option>
        <volist name=":get_source_list()" id="vo">
          <option value="{$vo.id}" {:selected($vo['id'],$_GET['source'])}>{$vo.name}</option>
        </volist>
      </select>
      <select name="level" id="level" onchange="searchForm.submit()" style="width: 123px;">
        <option value="0">请选择级别</option>
        <volist name=":levelArr()" id="vo">
          <option value="{$key}" {:selected($key,$_GET['level'])} >{$vo}</option>
        </volist>
      </select>

      <input type="submit" value=" 搜索 " class="button" id="searchButton" />
    </form>
  </div>
</div>
<!--subnav-->
<div class="pad-lr-10">
  <form name="myform" id="myform" action="" method="post">
    <div class="table-list">
      <table width="100%" cellspacing="0">
        <thead>
          <tr>
            <th width="50" align="center">序号</th>
            <th align="center">录入时间</a></th>
            <th align="center">学员名称</th>
            <th align="center"><a href="__ACTION__/sort_level/{$sort_level|default=1}">意向级别<i class="th-sort"><img src="/Public/images/px.gif"></i></a></th>
            <th align="center"><a href="__ACTION__/sort_rank/{$sort_rank|default=1}">详细级别<i class="th-sort"><img src="/Public/images/px.gif"></i></a></th>
            <th align="center">所在地</th>
            <th align="center">课程项目</th>
            <th align="center">详细课程</th>
            <th align="center">联系电话</th>
            <th align="center">QQ</th>
            <!-- <th align="center">微信</th> -->
            <th align="center">上次跟进</th>
            <th align="center">剩余天数</th>
            <th align="center"><a href="__ACTION__/talk_time2_sort/{$talk_time2_sort|default=1}">下次跟进<i class="th-sort"><img src="/Public/images/px.gif"></i></a></th>
            <th align="center">电话内容</th>
            <th align="center">所属顾问</th>
            <th align="center">咨询方式</th>
            <th align="center">跟进次数</th>
          </tr>
        </thead>
        <tbody  id="list">
          <volist name="list" id="vo">
            <tr id="list-{$vo.id}" value="{$vo.id}" class="customer_list {$vo.class}" show="0">
              <td align="center">{$i}</td>
              <td align="center">{$vo.create_time|mydate2}</td>
              <td align="center">{$vo.name}</td>
              <td align="center">{$vo.level|get_level_name}</td>
              <td align="center">{$vo.level_text}</td>
              <td align="center">{$vo.address}</td>
              <td align="center">{$vo.course|get_course_name}</td>
              <td align="center">{$vo.course_text}</td>
              <td align="center">{$vo.phone}</td>
              <td align="center">{$vo.qq}</td>
              <!-- <td align="center">{$vo.wechat}</td> -->
              <td align="center">{$vo.talk_time|mydate2}</td>
              <td align="center">{:time_diff($notTime,$vo['talk_time2'])}</td>
              <td align="center">{$vo.talk_time2|mydate2}</td>
              <td align="center" class="description" title="{$vo.content}" name="{$vo.id}">{$vo.content|cut=30}</td>
              <td align="center">{$vo.user_id|get_counselor_name}</td>
              <td align="center">{$vo.source|get_source_name}</td>
              <td align="center" class="talk_num">{$vo.talk_num}</td>
              </td>
            </tr>
          </volist>
        </tbody>
      </table>
      <div class="btn">
        <div id="pages">{$page}</div>
      </div>
    </div>
  </form>
</div>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(e) {


  //全反选
  $("#checkall").click(function(){
    $("input[name=idArr[]]").each(function(){
      if(this.checked == false)
        this.checked = true;
      else
          this.checked = false;
    });
  });



  //异步获取通话记录
  $(".description").click(function(event) {
    var id = $(this).attr('name');
    var show = $("#list-"+id).attr('show');
    var num = $(this).siblings('.talk_num').html();
    alert(id);
    if(num<1) return false; //当电话记录为空的时候返回false

    if(show==0){
      set_record_list(id);
      $("#list-"+id).attr('show',1);
    }else if(show==1){
      $(".record-"+id).hide();
      $("#list-"+id).attr('show',2);
    }else{
      $(".record-"+id).show();
      $("#list-"+id).attr('show',1);
    }

  });

  //异步判断电话号码是否存在
  $("#phone").change(function(){
    var phone = $(this).val();
    if(phone=='') {
      $(this).next().html('');
      return false;
    }

    $.get("__CONTROLLER__/check_phone", { phone: phone },
    function(data){
      if(data.status==1){
        $(".phone-prompt").html(data.info);
      }else{
        $(".phone-prompt").html('');
      }
    });
  })

});


function set_record_list(id){
  $.ajax({
      type:'GET',
      url:"__CONTROLLER__/get_record_list",
      dataType:'text',
      data:encodeURI('id='+id),
      beforeSend:function(){
        $('#list-'+id).after('<tr class="jiazai"><td align="center" colspan="10" style="color:#F00" >正在加载。。。</td></tr>');
        $('.call-records').hide();
        $('.current-bg').removeClass('current-bg');
      },
      success:function(data){
        var data = eval('('+data+')');
        $('#list-'+id).after(data.data);
          $('#list-'+id).addClass('current-bg');
        $('#content-'+id).addClass('current-bg');
      },
      complete: function(XMLHttpRequest, textStatus){
        $('.jiazai').remove();
      },
      error: function(){}
    });
    return true;
}


</script>
